﻿using VOL.RabbitMq.RabbitMqDto;

namespace VOL.RabbitMq.IRabbitMq;

public interface IRabbitMqClient
{
    #region 配置操作



    #endregion

    #region 启停操作

    /// <summary>
    /// 客户端连接
    /// </summary>
    /// <returns></returns>
    Boolean ReConnect();
    /// <summary>
    /// 客户端连接
    /// </summary>
    /// <returns></returns>
    Task<Boolean> ConnectAsync();
    /// <summary>
    /// 客户端断开
    /// </summary>
    /// <returns></returns>
    Boolean Disconnect();
    /// <summary>
    /// 客户端断开
    /// </summary>
    /// <returns></returns>
    Task<Boolean> DisconnectAsync();

    #endregion


    #region 交换机--队列操作


    /// <summary>
    /// 创建交换机
    /// </summary>
    /// <param name="ExchangeType">交换机类型</param>
    /// <returns></returns>
    Boolean AddeExchange(string ExchangeName, string ExchangeType);

    /// <summary>
    /// 创建交换机
    /// </summary>
    /// <param name="ExchangeType">交换机类型</param>
    /// <returns></returns>
    Task<Boolean> AddeExchangeAsync(string ExchangeName, string ExchangeType);

    /// <summary>
    /// 删除交换机
    /// </summary>
    /// <param name="ExchangeType">交换机名称</param>
    /// <returns></returns>
    Boolean DelExchange(string ExchangeName);

    /// <summary>
    /// 删除交换机
    /// </summary>
    /// <param name="ExchangeType">交换机名称</param>
    /// <returns></returns>
    Task<Boolean> DelExchangeAsync(string ExchangeName);



    /// <summary>
    /// 创建队列
    /// </summary>
    /// <param name="queuename">队列名</param>
    /// <returns></returns>
    Boolean AddQueue(string queuename);

    /// <summary>
    /// 创建队列
    /// </summary>
    /// <param name="queuename">队列名</param>
    /// <param name="durable">是否持久化</param>
    /// <returns></returns>
    Boolean AddQueue(string queuename, bool durable);


    /// <summary>
    /// 创建队列
    /// </summary>
    /// <param name="queuename">队列名</param>
    /// <param name="durable">是否持久化</param>
    /// <param name="exclusive">是否排他</param>
    /// <param name="autoDelete">自动删除</param>
    /// <returns></returns>
    Boolean AddQueue(string queuename, bool durable, bool exclusive, bool autoDelete);


    /// <summary>
    /// 删除队列
    /// </summary>
    /// <param name="queuename">队列名称</param>
    /// <returns></returns>
    Boolean DelQueue(string queuename);

    #endregion




    #region 发布操作


    /// <summary>
    /// 客户端发布
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="exchangeName">交换机名称</param>
    /// <param name="routingKey">路由名称</param>
    /// <param name="payload">信息内容</param>
    /// <returns></returns>
    Task<RabbitMqResultDto> PublishAsync(string exchangeName, string routingKey, RabbitSendDto<dynamic> payload);

    #endregion


    #region 订阅操作


    /// <summary>
    /// 客户端订阅
    /// </summary>
    /// <param name="exchangeName">交换机名称</param>
    /// <param name="routingKey">路由名称</param>
    /// <param name="autoAck">是否自动应答</param>
    /// <returns></returns>
    Task<bool> SubscribeAsync(string exchangeName, string routingKey, bool autoAck);

    #endregion
}